
#pragma once

#include "DirectXMath.h"
#include "DirectXPackedVector.h"
#include "DirectXCollision.h"

namespace FlameEngineMath
{
	typedef DirectX::XMVECTOR Vector4;
	typedef DirectX::XMMATRIX Matrix;

	/*********************************************************
	Remark:
	Use the Vector4Param alias to pass up to the first three instances of Vector4 used as arguments to a function.
	Use the Vector4Param4 alias to pass the 4th instance of an Vector4 used as an argument
	Use the Vector4ParamX alias to pass any further instances of Vector4 used as arguments.

	For output parameters, always use Vector4Param* or Vector4Param& and ignore them with respect to the the rules above for input parameters.

	For 32-bit Windows:
	typedef const Vector4 FXMVECTOR;
	typedef const Vector4& Vector4Param4;
	typedef const Vector4& Vector4ParamX;

	For 64-bit Windows:
	typedef const Vector4& FXMVECTOR;
	typedef const Vector4& Vector4Param4;
	typedef const Vector4& Vector4ParamX;
	
	Windows on ARM:
	typedef const Vector4 FXMVECTOR;
	typedef const Vector4 Vector4Param4;
	typedef const Vector4& Vector4ParamX;
	see http://msdn.microsoft.com/en-us/library/ee418728(v=VS.85).aspx for more details
	*********************************************************/
	typedef DirectX::FXMVECTOR Vector4Param;
	typedef DirectX::GXMVECTOR Vector4Param4;
	typedef DirectX::CXMVECTOR Vector4ParamX;

	typedef DirectX::CXMMATRIX MatrixParam;

	typedef DirectX::XMFLOAT2 Float2;
	typedef DirectX::XMFLOAT2A Float2A;
	typedef DirectX::XMINT2 Int2;
	typedef DirectX::XMUINT2 UInt2;
	
	typedef DirectX::XMFLOAT3 Float3;
	typedef DirectX::XMFLOAT3A Float3A;
	typedef DirectX::XMINT3 Int3;
	typedef DirectX::XMUINT3 UInt3;

	typedef DirectX::XMFLOAT4 Float4;
	typedef DirectX::XMFLOAT4A Float4A;
	typedef DirectX::XMINT4 Int4;
	typedef DirectX::XMUINT4 UInt4;

	typedef DirectX::XMFLOAT3X3 Float3x3;
	typedef DirectX::XMFLOAT4X3 Float4x3;
	typedef DirectX::XMFLOAT4X3A Float4x3A;
	typedef DirectX::XMFLOAT4X4 Float4x4;
	typedef DirectX::XMFLOAT4X4A Float4x4A;


	class MathHelper
	{
	public:
		static const float Pi;
		static const float TwoPi;
		static const float OneDivPi;
		static const float OneDiv2Pi;
		static const float PiDiv2;
		static const float PiDiv4;

	public:
		static inline Vector4 FresnelTerm(Vector4Param CosIncidentAngle, Vector4Param RefractionIndex){return DirectX::XMFresnelTerm(CosIncidentAngle,RefractionIndex);}

		static inline bool ScalarNearEqual(float S1, float S2, float Epsilon){return DirectX::XMScalarNearEqual(S1,S2,Epsilon);}

		static inline float ScalarModAngle(float Value){return DirectX::XMScalarModAngle(Value);}

		/*
		Est functions offer increased performance at the expense of reduced accuracy. 
		Est functions are appropriate for non-critical calculations 
		where accuracy can be sacrificed for speed. 
		*/
		static inline float ScalarSin(float Value){return DirectX::XMScalarSin(Value);}
		static inline float ScalarSinEst(float Value){return DirectX::XMScalarSinEst(Value);}
			  
		static inline float ScalarCos(float Value){return DirectX::XMScalarCos(Value);}
		static inline float ScalarCosEst(float Value){return DirectX::XMScalarCosEst(Value);}
			  
		static inline void  ScalarSinCos(_Out_ float* pSin, _Out_ float* pCos, float Value){return DirectX::XMScalarSinCos(pSin,pCos,Value);}
		static inline void  ScalarSinCosEst(_Out_ float* pSin, _Out_ float* pCos, float Value){return DirectX::XMScalarSinCosEst(pSin,pCos,Value);}
			  
		static inline float ScalarASin(float Value){return DirectX::XMScalarASin(Value);}
		static inline float ScalarASinEst(float Value){return DirectX::XMScalarASinEst(Value);}
			  
		static inline float ScalarACos(float Value){return DirectX::XMScalarACos(Value);}
		static inline float ScalarACosEst(float Value){return DirectX::XMScalarACosEst(Value);}


		/**********************************************************************************
		* Below are operations for non-SIMD data type,e.g. Float2,Float3,Float4,etc...
		***********************************************************************************/
		//Float2
		inline static void Add(const Float2& vec1,const Float2& vec2,Float2& result);
		inline static void Subtract(const Float2& vec1,const Float2& vec2,Float2& result);
		inline static void Multiply(const Float2& vec1,const Float2& vec2,Float2& result);
		inline static void Multiply(const Float2& vec1,float scalar,Float2& result);
		inline static void Divide(const Float2& vec1,const Float2& vec2,Float2& result);
		inline static void Divide(const Float2& vec1,float scalar,Float2& result);
		inline static void Normalize(const Float2& vec,Float2& result,float epsilon = 0.0000001);
		inline static float Dot(const Float2& vec1,const Float2& vec2);
		inline static void Lerp(const Float2& vec1,const Float2& vec2,float weight,Float2 result);
		inline static void Max(const Float2& vec1,const Float2& vec2,Float2& result);
		inline static void Min(const Float2& vec1,const Float2& vec2,Float2& result);

		inline static bool NearEqual(const Float2& f1,const Float2& f2,float epsilon);

		/*not implement yet
		static void Transform(const Float2& vec,const Matrix& mat,Float2& result);
		static void Transform(const Float2& vec,const Quaternion& quat,Float2& result);
		static void TransformNormal(const Float2& vec,const Matrix& mat,Float2& result);
		*/

		//Float3
		inline static void Add(const Float3& vec1,const Float3& vec2,Float3& result);
		inline static void Subtract(const Float3& vec1,const Float3& vec2,Float3& result);
		inline static void Multiply(const Float3& vec1,const Float3& vec2,Float3& result);
		inline static void Multiply(const Float3& vec1,float scalar,Float3& result);
		inline static void Divide(const Float3& vec1,const Float3& vec2,Float3& result);
		inline static void Divide(const Float3& vec1,float scalar,Float3& result);
		inline static void Normalize(const Float3& vec,Float3& result,float epsilon = 0.0000001);
		inline static float Dot(const Float3& vec1,const Float3& vec2);
		inline static void Cross(const Float3& vec1,const Float3& vec2,Float3& result);
		inline static void Lerp(const Float3& vec1,const Float3& vec2,float weight,Float3& result);
		inline static void Max(const Float3& vec1,const Float3& vec2,Float3& result);
		inline static void Min(const Float3& vec1,const Float3& vec2,Float3& result);

		inline static bool NearEqual(const Float3& f1,const Float3& f2,float epsilon);

		//float4
		inline static void Add(const Float4& vec1,const Float4& vec2,Float4& result);
		inline static void Subtract(const Float4& vec1,const Float4& vec2,Float4& result);
		inline static void Multiply(const Float4& vec1,const Float4& vec2,Float4& result);
		inline static void Multiply(const Float4& vec1,float scalar,Float4& result);
		inline static void Divide(const Float4& vec1,const Float4& vec2,Float4& result);
		inline static void Divide(const Float4& vec1,float scalar,Float4& result);
		inline static void Normalize(const Float4& vec,Float4& result,float epsilon = 0.0000001);
		inline static float Dot(const Float4& vec1,const Float4& vec2);
		inline static void Lerp(const Float4& vec1,const Float4& vec2,float weight,Float4& result);
		inline static void Max(const Float4& vec1,const Float4& vec2,Float4& result);
		inline static void Min(const Float4& vec1,const Float4& vec2,Float4& result);

		inline static bool NearEqual(const Float4& f1,const Float4& f2,float epsilon);

		//quaternion
		inline static void MultiplyQuaternion(const Float4& q1,const Float4& q2,Float4& result);
		inline static void MultiplyQuaternion(const Float4& q1,float scalar,Float4& result);
		inline static void LerpQuaternion(const Float4& q1,const Float4& q2,float weight,Float4& result);
		inline static void SlerpQuaternion(const Float4& q1,const Float4& q2,float weight,Float4& result);
		inline static void ConjugateQuaternion(const Float4& q,Float4& result);
		inline static void InvertQuaternion(const Float4& src,Float4& inv);

		inline static void CreateFromAxisAngle(const Float3& axis,float radian,Float4& result);
		inline static void CreateFromPitchYawRoll(float pitch,float yaw,float roll,Float4& result);
		inline static void CreateFromPitchYawRoll(Float3& radians,Float4& result);
		inline static void CreateFromRotationMatrix(Float4x4& mat,Float4& result);

		//matrix3x3
		inline static void Add(const Float3x3& mat1,const Float3x3& mat2,Float3x3& result);
		inline static void Subtract(const Float3x3& mat1,const Float3x3& mat2,Float3x3& result);
		inline static void Multiply(const Float3x3& mat1,const Float3x3& mat2,Float3x3& result);
		inline static void Multiply(const Float3x3& mat,float scalar,Float3x3& result);
		inline static void Negate(const Float3x3& mat,Float3x3& result);
		inline static void Invert(const Float3x3& mat,Float3x3& result);
		inline static void Transpose(const Float3x3& mat,Float3x3& result);
		inline static void Lerp(const Float3x3& mat1,const Float3x3& mat2,float weight,Float3x3& result);
		inline static float Determinant(const Float3x3& mat);
		inline static void CreateTranslation(float x0,float y0,Float3x3& result);
		inline static void CreateTranslation(const Float2& pos,Float3x3& result);
		inline static void CreateRotationX(float radian,Float3x3& result);
		inline static void CreateRotationY(float radian,Float3x3& result);
		inline static void CreateRotationZ(float radian,Float3x3& result);
		inline static void CreateFromAxisAngle(const Float3& unitVec,float radian,Float3x3& result);
		inline static void CreateFromQuaternion(const Float4& quat,Float3x3& result);
		inline static void CreateFromPitchYawRoll(float pitch,float yaw,float roll,Float3x3& result);
		inline static void CreateFromPitchYawRoll(const Float3& radian,Float3x3& result);
		inline static void CreateScale(float xScale,float yScale,float zScale,Float3x3& result);
		inline static void CreateScale(const Float3& scale,Float3x3& result);
		inline static void Transform(const Float3x3& mat,const Float4& quat,Float3x3& result);

		//matrix4x4
		inline static void Add(const Float4x4& mat1,const Float4x4& mat2,Float4x4& result);
		inline static void Subtract(const Float4x4& mat1,const Float4x4& mat2,Float4x4& result);
		inline static void Multiply(const Float4x4& mat1,const Float4x4& mat2,Float4x4& result);
		inline static void Multiply(const Float4x4& mat1,float scalar,Float4x4& result);
		inline static void Negate(const Float4x4& mat, Float4x4& result);
		inline static void Invert(const Float4x4& mat, Float4x4& result);
		inline static void Transpose(const Float4x4& mat,Float4x4& result);
		inline static void Lerp(const Float4x4& mat1,const Float4x4& mat2,float weight,Float4x4& result);
		inline static float Determinant(const Float4x4& mat);

		inline static void CreateFromPitchYawRoll(float pitch,float yaw,float roll,Float4x4& result);
		inline static void CreateFromPitchYawRoll(const Float3& radian,Float4x4& result);
		inline static void CreateFromAxisAngle(const Float3& unitVec,float radian,Float4x4& result);
		inline static void CreateRotationX(float radian,Float4x4& result);
		inline static void CreateRotationY(float radian,Float4x4& result);
		inline static void CreateRotationZ(float radian,Float4x4& result);
		inline static void CreateScale(float x,float y,float z,Float4x4& result);
		inline static void CreateScale(Float3& scale,Float4x4& result);
		inline static void CreateTranslation(float x,float y,float z,Float4x4& result);
		inline static void CreateTranslation(Float3& position,Float4x4& result);
		inline static void Transform(const Float4x4& mat,const Float4& quat,Float4x4& result);

		inline static void CreateLookAtRH(Float3& eyePos,Float3& target,Float3& up,Float4x4& result);
		inline static void CreatePerspectiveFovRH(float fov,float aspectRatio,float near,float far,Float4x4& result);
		inline static void CreateFromQuaternion(const Float4& quat,Float4x4& result);
	};

	/****************************************************************************
	 *
	 * Load operations
	 *
	 ****************************************************************************/
	inline Vector4 LoadInt(_In_ const uint32_t* pSource){return DirectX::XMLoadInt(pSource);}
	inline Vector4 LoadFloat(_In_ const float* pSource){return DirectX::XMLoadFloat(pSource);}

	inline Vector4 LoadInt2(_In_reads_(2) const uint32_t* pSource){return DirectX::XMLoadInt2(pSource);}
	inline Vector4 LoadInt2A(_In_reads_(2) const uint32_t* pSource){return DirectX::XMLoadInt2A(pSource);};
	inline Vector4 LoadFloat2(_In_ const Float2* pSource){return DirectX::XMLoadFloat2(pSource);};
	inline Vector4 LoadFloat2A(_In_ const Float2A* pSource){return DirectX::XMLoadFloat2A(pSource);};
	inline Vector4 LoadSInt2(_In_ const Int2* pSource){return DirectX::XMLoadSInt2(pSource);};
	inline Vector4 LoadUInt2(_In_ const UInt2* pSource){return DirectX::XMLoadUInt2(pSource);};

	inline Vector4 LoadInt3(_In_reads_(3) const uint32_t* pSource){return DirectX::XMLoadInt3(pSource);};
	inline Vector4 LoadInt3A(_In_reads_(3) const uint32_t* pSource){return DirectX::XMLoadInt3A(pSource);};
	inline Vector4 LoadFloat3(_In_ const Float3* pSource){return DirectX::XMLoadFloat3(pSource);};
	inline Vector4 LoadFloat3A(_In_ const Float3A* pSource){return DirectX::XMLoadFloat3A(pSource);};
	inline Vector4 LoadSInt3(_In_ const Int3* pSource){return DirectX::XMLoadSInt3(pSource);};
	inline Vector4 LoadUInt3(_In_ const UInt3* pSource){return DirectX::XMLoadUInt3(pSource);};

	inline Vector4 LoadInt4(_In_reads_(4) const uint32_t* pSource){return DirectX::XMLoadInt4(pSource);};
	inline Vector4 LoadInt4A(_In_reads_(4) const uint32_t* pSource){return DirectX::XMLoadInt4A(pSource);};
	inline Vector4 LoadFloat4(_In_ const Float4* pSource){return DirectX::XMLoadFloat4(pSource);};
	inline Vector4 LoadFloat4A(_In_ const Float4A* pSource){return DirectX::XMLoadFloat4A(pSource);};
	inline Vector4 LoadSInt4(_In_ const Int4* pSource){return DirectX::XMLoadSInt4(pSource);};
	inline Vector4 LoadUInt4(_In_ const UInt4* pSource){return DirectX::XMLoadUInt4(pSource);};

	inline Matrix LoadFloat3x3(_In_ const Float3x3* pSource){return DirectX::XMLoadFloat3x3(pSource);};
	inline Matrix LoadFloat4x3(_In_ const Float4x3* pSource){return DirectX::XMLoadFloat4x3(pSource);};
	inline Matrix LoadFloat4x3A(_In_ const Float4x3A* pSource){return DirectX::XMLoadFloat4x3A(pSource);};
	inline Matrix LoadFloat4x4(_In_ const Float4x4* pSource){return DirectX::XMLoadFloat4x4(pSource);};
	inline Matrix LoadFloat4x4A(_In_ const Float4x4A* pSource){return DirectX::XMLoadFloat4x4A(pSource);};

	/****************************************************************************
	*
	* Store operations
	*
	****************************************************************************/
	inline void StoreInt(_Out_ uint32_t* pDestination, _In_ Vector4Param V){DirectX::XMStoreInt(pDestination,V);}
	inline void StoreFloat(_Out_ float* pDestination, _In_ Vector4Param V){DirectX::XMStoreFloat(pDestination,V);};

	inline void StoreInt2(_Out_writes_(2) uint32_t* pDestination, _In_ Vector4Param V){DirectX::XMStoreInt2(pDestination,V);};
	inline void StoreInt2A(_Out_writes_(2) uint32_t* pDestination, _In_ Vector4Param V){DirectX::XMStoreInt2A(pDestination,V);};
	inline void StoreFloat2(_Out_ Float2* pDestination, _In_ Vector4Param V){DirectX::XMStoreFloat2(pDestination,V);};
	inline void StoreFloat2A(_Out_ Float2A* pDestination, _In_ Vector4Param V){DirectX::XMStoreFloat2A(pDestination,V);};
	inline void StoreSInt2(_Out_ Int2* pDestination, _In_ Vector4Param V){DirectX::XMStoreSInt2(pDestination,V);};
	inline void StoreUint2(_Out_ UInt2* pDestination, _In_ Vector4Param V){DirectX::XMStoreUInt2(pDestination,V);};

	inline void StoreInt3(_Out_writes_(3) uint32_t* pDestination, _In_ Vector4Param V){DirectX::XMStoreInt3(pDestination,V);};
	inline void StoreInt3A(_Out_writes_(3) uint32_t* pDestination, _In_ Vector4Param V){DirectX::XMStoreInt3A(pDestination,V);};
	inline void StoreFloat3(_Out_ Float3* pDestination, _In_ Vector4Param V){DirectX::XMStoreFloat3(pDestination,V);};
	inline void StoreFloat3A(_Out_ Float3A* pDestination, _In_ Vector4Param V){DirectX::XMStoreFloat3A(pDestination,V);};
	inline void StoreSInt3(_Out_ Int3* pDestination, _In_ Vector4Param V){DirectX::XMStoreSInt3(pDestination,V);};
	inline void StoreUint3(_Out_ UInt3* pDestination, _In_ Vector4Param V){DirectX::XMStoreUInt3(pDestination,V);};
	
	inline void StoreInt4(_Out_writes_(4) uint32_t* pDestination, _In_ Vector4Param V){DirectX::XMStoreInt4(pDestination,V);};
	inline void StoreInt4A(_Out_writes_(4) uint32_t* pDestination, _In_ Vector4Param V){DirectX::XMStoreInt4A(pDestination,V);};
	inline void StoreFloat4(_Out_ Float4* pDestination, _In_ Vector4Param V){DirectX::XMStoreFloat4(pDestination,V);};
	inline void StoreFloat4A(_Out_ Float4A* pDestination, _In_ Vector4Param V){DirectX::XMStoreFloat4A(pDestination,V);};
	inline void StoreSInt4(_Out_ Int4* pDestination, _In_ Vector4Param V){DirectX::XMStoreSInt4(pDestination,V);};
	inline void StoreUint4(_Out_ UInt4* pDestination, _In_ Vector4Param V){DirectX::XMStoreUInt4(pDestination,V);};
	
	inline void StoreFloat3x3(_Out_ Float3x3* pDestination, _In_ MatrixParam M){DirectX::XMStoreFloat3x3(pDestination,M);};
	inline void StoreFloat4x3(_Out_ Float4x3* pDestination, _In_ MatrixParam M){DirectX::XMStoreFloat4x3(pDestination,M);};
	inline void StoreFloat4x3A(_Out_ Float4x3A* pDestination, _In_ MatrixParam M){DirectX::XMStoreFloat4x3A(pDestination,M);};
	inline void StoreFloat4x4(_Out_ Float4x4* pDestination, _In_ MatrixParam M){DirectX::XMStoreFloat4x4(pDestination,M);};
	inline void StoreFloat4x4A(_Out_ Float4x4A* pDestination, _In_ MatrixParam M){DirectX::XMStoreFloat4x4A(pDestination,M);};

	 /****************************************************************************
	 *
	 * General vector operations
	 *
	 ****************************************************************************/
	inline Vector4 VectorZero(){return DirectX::XMVectorZero();}
	inline Vector4 VectorSet(float x, float y, float z, float w){return DirectX::XMVectorSet(x,y,z,w);}
	inline Vector4 VectorSetInt(uint32_t x, uint32_t y, uint32_t z, uint32_t w){return DirectX::XMVectorSetInt(x,y,z,w);}
	inline Vector4 VectorReplicate(float Value){return DirectX::XMVectorReplicate(Value);}
	inline Vector4 VectorReplicatePtr(_In_ const float *pValue){return DirectX::XMVectorReplicatePtr(pValue);}
	inline Vector4 VectorReplicateInt(uint32_t Value){return DirectX::XMVectorReplicateInt(Value);}
	inline Vector4 VectorReplicateIntPtr(_In_ const uint32_t *pValue){return DirectX::XMVectorReplicateIntPtr(pValue);}
	inline Vector4 VectorTrueInt(){return DirectX::XMVectorTrueInt();}
	inline Vector4 VectorFalseInt(){return DirectX::XMVectorFalseInt();}
	inline Vector4 VectorSplatX(Vector4Param V){return DirectX::XMVectorSplatX(V);}
	inline Vector4 VectorSplatY(Vector4Param V){return DirectX::XMVectorSplatY(V);}
	inline Vector4 VectorSplatZ(Vector4Param V){return DirectX::XMVectorSplatZ(V);}
	inline Vector4 VectorSplatW(Vector4Param V){return DirectX::XMVectorSplatW(V);}
	inline Vector4 VectorSplatOne(){return DirectX::XMVectorSplatOne();}
	inline Vector4 VectorSplatInfinity(){return DirectX::XMVectorSplatInfinity();}
	inline Vector4 VectorSplatQNaN(){return DirectX::XMVectorSplatQNaN();};
	inline Vector4 VectorSplatEpsilon(){return DirectX::XMVectorSplatEpsilon();}
	inline Vector4 VectorSplatSignMask(){return DirectX::XMVectorSplatSignMask();}

	inline float VectorGetByIndex(Vector4Param V,size_t i){return DirectX::XMVectorGetByIndex(V,i);}
	inline float VectorGetX(Vector4Param V){return DirectX::XMVectorGetX(V);}
	inline float VectorGetY(Vector4Param V){return DirectX::XMVectorGetY(V);}
	inline float VectorGetZ(Vector4Param V){return DirectX::XMVectorGetZ(V);}
	inline float VectorGetW(Vector4Param V){return DirectX::XMVectorGetW(V);}
		  
	inline void VectorGetByIndexPtr(_Out_ float *f, _In_ Vector4Param V, _In_ size_t i){return DirectX::XMVectorGetByIndexPtr(f,V,i);}
	inline void VectorGetXPtr(_Out_ float *x, _In_ Vector4Param V){return DirectX::XMVectorGetXPtr(x,V);}
	inline void VectorGetYPtr(_Out_ float *y, _In_ Vector4Param V){return DirectX::XMVectorGetYPtr(y,V);}
	inline void VectorGetZPtr(_Out_ float *z, _In_ Vector4Param V){return DirectX::XMVectorGetZPtr(z,V);}
	inline void VectorGetWPtr(_Out_ float *w, _In_ Vector4Param V){return DirectX::XMVectorGetWPtr(w,V);}

	inline uint32_t VectorGetIntByIndex(Vector4Param V, size_t i){return DirectX::XMVectorGetIntByIndex(V,i);}
	inline uint32_t VectorGetIntX(Vector4Param V){return DirectX::XMVectorGetIntX(V);}
	inline uint32_t VectorGetIntY(Vector4Param V){return DirectX::XMVectorGetIntY(V);}
	inline uint32_t VectorGetIntZ(Vector4Param V){return DirectX::XMVectorGetIntZ(V);}
	inline uint32_t VectorGetIntW(Vector4Param V){return DirectX::XMVectorGetIntW(V);}

	inline void VectorGetIntByIndexPtr(_Out_ uint32_t *x, _In_ Vector4Param V, _In_ size_t i){return DirectX::XMVectorGetIntByIndexPtr(x,V,i);}
	inline void VectorGetIntXPtr(_Out_ uint32_t *x, _In_ Vector4Param V){return DirectX::XMVectorGetIntXPtr(x,V);}
	inline void VectorGetIntYPtr(_Out_ uint32_t *y, _In_ Vector4Param V){return DirectX::XMVectorGetIntYPtr(y,V);}
	inline void VectorGetIntZPtr(_Out_ uint32_t *z, _In_ Vector4Param V){return DirectX::XMVectorGetIntZPtr(z,V);}
	inline void VectorGetIntWPtr(_Out_ uint32_t *w, _In_ Vector4Param V){return DirectX::XMVectorGetIntWPtr(w,V);}

	inline Vector4 VectorSetByIndex(Vector4Param V,float f, size_t i){return DirectX::XMVectorSetByIndex(V,f,i);}
	inline Vector4 VectorSetX(Vector4Param V, float x){return DirectX::XMVectorSetX(V,x);}
	inline Vector4 VectorSetY(Vector4Param V, float y){return DirectX::XMVectorSetY(V,y);}
	inline Vector4 VectorSetZ(Vector4Param V, float z){return DirectX::XMVectorSetZ(V,z);}
	inline Vector4 VectorSetW(Vector4Param V, float w){return DirectX::XMVectorSetW(V,w);}

	inline Vector4 VectorSetByIndexPtr(_In_ Vector4Param V, _In_ const float *f, _In_ size_t i){return DirectX::XMVectorSetByIndexPtr(V,f,i);}
	inline Vector4 VectorSetXPtr(_In_ Vector4Param V, _In_ const float *x){return DirectX::XMVectorSetXPtr(V,x);}
	inline Vector4 VectorSetYPtr(_In_ Vector4Param V, _In_ const float *y){return DirectX::XMVectorSetYPtr(V,y);}
	inline Vector4 VectorSetZPtr(_In_ Vector4Param V, _In_ const float *z){return DirectX::XMVectorSetZPtr(V,z);}
	inline Vector4 VectorSetWPtr(_In_ Vector4Param V, _In_ const float *w){return DirectX::XMVectorSetWPtr(V,w);}

	inline Vector4 VectorSetIntByIndex(Vector4Param V, uint32_t x, size_t i){return DirectX::XMVectorSetIntByIndex(V,x,i);}
	inline Vector4 VectorSetIntX(Vector4Param V, uint32_t x){return DirectX::XMVectorSetIntX(V,x);}
	inline Vector4 VectorSetIntY(Vector4Param V, uint32_t y){return DirectX::XMVectorSetIntY(V,y);}
	inline Vector4 VectorSetIntZ(Vector4Param V, uint32_t z){return DirectX::XMVectorSetIntZ(V,z);}
	inline Vector4 VectorSetIntW(Vector4Param V, uint32_t w){return DirectX::XMVectorSetIntW(V,w);}

	inline Vector4 VectorSetIntByIndexPtr(_In_ Vector4Param V, _In_ const uint32_t *x, _In_ size_t i){return DirectX::XMVectorSetIntByIndexPtr(V,x,i);}
	inline Vector4 VectorSetIntXPtr(_In_ Vector4Param V, _In_ const uint32_t *x){return DirectX::XMVectorSetIntXPtr(V,x);}
	inline Vector4 VectorSetIntYPtr(_In_ Vector4Param V, _In_ const uint32_t *y){return DirectX::XMVectorSetIntYPtr(V,y);}
	inline Vector4 VectorSetIntZPtr(_In_ Vector4Param V, _In_ const uint32_t *z){return DirectX::XMVectorSetIntZPtr(V,z);}
	inline Vector4 VectorSetIntWPtr(_In_ Vector4Param V, _In_ const uint32_t *w){return DirectX::XMVectorSetIntWPtr(V,w);}

	inline Vector4 VectorSwizzle(Vector4Param V, uint32_t E0, uint32_t E1, uint32_t E2, uint32_t E3){return DirectX::XMVectorSwizzle(V,E0,E1,E2,E3);}
	inline Vector4 VectorPermute(Vector4Param V1, Vector4Param V2, uint32_t PermuteX, uint32_t PermuteY, uint32_t PermuteZ, uint32_t PermuteW)
	{
		return DirectX::XMVectorPermute(V1,V2,PermuteX,PermuteY,PermuteZ,PermuteW);
	}
	inline Vector4 VectorSelectControl(uint32_t VectorIndex0, uint32_t VectorIndex1, uint32_t VectorIndex2, uint32_t VectorIndex3)	
	{
		return DirectX::XMVectorSelectControl(VectorIndex0,VectorIndex1,VectorIndex2,VectorIndex3);
	}
	inline Vector4 VectorSelect(Vector4Param V1, Vector4Param V2, Vector4Param Control){return DirectX::XMVectorSelect(V1,V2,Control);}
	inline Vector4 VectorMergeXY(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorMergeXY(V1,V2);}
	inline Vector4 VectorMergeZW(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorMergeZW(V1,V2);}

	inline Vector4 VectorShiftLeft(Vector4Param V1, Vector4Param V2, uint32_t Elements){return DirectX::XMVectorShiftLeft(V1,V2,Elements);}
	inline Vector4 VectorRotateLeft(Vector4Param V, uint32_t Elements){return DirectX::XMVectorRotateLeft(V,Elements);}
	inline Vector4 VectorRotateRight(Vector4Param V, uint32_t Elements){return DirectX::XMVectorRotateRight(V,Elements);}
	inline Vector4 VectorInsert(Vector4Param VD, Vector4Param VS, uint32_t VSLeftRotateElements,uint32_t Select0, uint32_t Select1, uint32_t Select2, uint32_t Select3)
	{
		return	DirectX::XMVectorInsert(VD,VS,VSLeftRotateElements,Select0,Select1,Select2,Select3);
	}

	inline Vector4 VectorEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorEqual(V1,V2);}
	inline Vector4 VectorEqualR(_Out_ uint32_t* pCR, _In_ Vector4Param V1, _In_ Vector4Param V2){return DirectX::XMVectorEqualR(pCR,V1,V2);}
	inline Vector4 VectorEqualInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorEqualInt(V1,V2);}
	inline Vector4 VectorEqualIntR(_Out_ uint32_t* pCR, _In_ Vector4Param V, _In_ Vector4Param V2){return DirectX::XMVectorEqualIntR(pCR,V,V2);}
	inline Vector4 VectorNearEqual(Vector4Param V1, Vector4Param V2, Vector4Param Epsilon){return DirectX::XMVectorNearEqual(V1,V2,Epsilon);}
	inline Vector4 VectorNotEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorNotEqual(V1,V2);}
	inline Vector4 VectorNotEqualInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorNotEqualInt(V1,V2);}
	inline Vector4 VectorGreater(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorGreater(V1,V2);}
	inline Vector4 VectorGreaterR(_Out_ uint32_t* pCR, _In_ Vector4Param V1, _In_ Vector4Param V2){return DirectX::XMVectorGreaterR(pCR,V1,V2);}
	inline Vector4 VectorGreaterOrEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorGreaterOrEqual(V1, V2);}
	inline Vector4 VectorGreaterOrEqualR(_Out_ uint32_t* pCR, _In_ Vector4Param V1, _In_ Vector4Param V2){return DirectX::XMVectorGreaterOrEqualR(pCR,V1,V2);}
	inline Vector4 VectorLess(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorLess(V1,V2);}
	inline Vector4 VectorLessOrEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorLessOrEqual(V1,V2);}
	inline Vector4 VectorInBounds(Vector4Param V, Vector4Param Bounds){return DirectX::XMVectorInBounds(V,Bounds);}
	inline Vector4 VectorInBoundsR(_Out_ uint32_t* pCR, _In_ Vector4Param V, _In_ Vector4Param Bounds){return DirectX::XMVectorInBoundsR(pCR,V,Bounds);}

	inline Vector4 VectorIsNaN(Vector4Param V){return DirectX::XMVectorIsNaN(V);}
	inline Vector4 VectorIsInfinite(Vector4Param V){return DirectX::XMVectorIsInfinite(V);}
			
	inline Vector4 VectorMin(Vector4Param V1,Vector4Param V2){return DirectX::XMVectorMin(V1,V2);}
	inline Vector4 VectorMax(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorMax(V1,V2);}
	inline Vector4 VectorRound(Vector4Param V){return DirectX::XMVectorRound(V);}
	inline Vector4 VectorTruncate(Vector4Param V){return DirectX::XMVectorTruncate(V);}
	inline Vector4 VectorFloor(Vector4Param V){return DirectX::XMVectorFloor(V);}
	inline Vector4 VectorCeiling(Vector4Param V){return DirectX::XMVectorCeiling(V);}
	inline Vector4 VectorClamp(Vector4Param V, Vector4Param Min, Vector4Param Max){return DirectX::XMVectorClamp(V,Min,Max);}
	inline Vector4 VectorSaturate(Vector4Param V){return DirectX::XMVectorSaturate(V);}
			
	inline Vector4 VectorAndInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorAndInt(V1,V2);}
	inline Vector4 VectorAndCInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorAndCInt(V1,V2);}
	inline Vector4 VectorOrInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorOrInt(V1,V2);}
	inline Vector4 VectorNorInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorNorInt(V1,V2);}
	inline Vector4 VectorXorInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorXorInt(V1,V2);}

	inline Vector4 VectorNegate(Vector4Param V){return DirectX::XMVectorNegate(V);}
	inline Vector4 VectorAdd(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorAdd(V1,V2);}
	inline Vector4 VectorAddAngles(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorAddAngles(V1,V2);}
	inline Vector4 VectorSubtract(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorSubtract(V1,V2);}
	inline Vector4 VectorSubtractAngles(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorSubtractAngles(V1,V2);}
	inline Vector4 VectorMultiply(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorMultiply(V1,V2);}
	inline Vector4 VectorMultiplyAdd(Vector4Param V1, Vector4Param V2, Vector4Param V3){return DirectX::XMVectorMultiplyAdd(V1,V2,V3);}
	inline Vector4 VectorDivide(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorDivide(V1,V2);}
	inline Vector4 VectorNegativeMultiplySubtract(Vector4Param V1, Vector4Param V2, Vector4Param V3){return DirectX::XMVectorNegativeMultiplySubtract(V1,V2,V3);}
	inline Vector4 VectorScale(Vector4Param V, float ScaleFactor){return DirectX::XMVectorScale(V,ScaleFactor);}
	inline Vector4 VectorReciprocalEst(Vector4Param V){return DirectX::XMVectorReciprocalEst(V);}
	inline Vector4 VectorReciprocal(Vector4Param V){return DirectX::XMVectorReciprocal(V);}
	inline Vector4 VectorSqrtEst(Vector4Param V){return DirectX::XMVectorSqrtEst(V);}
	inline Vector4 VectorSqrt(Vector4Param V){return DirectX::XMVectorSqrt(V);}
	inline Vector4 VectorReciprocalSqrtEst(Vector4Param V){return DirectX::XMVectorReciprocalSqrtEst(V);}
	inline Vector4 VectorReciprocalSqrt(Vector4Param V){return DirectX::XMVectorReciprocalSqrt(V);}
	inline Vector4 VectorExp(Vector4Param V){return DirectX::XMVectorExp(V);}
	inline Vector4 VectorLog(Vector4Param V){return DirectX::XMVectorLog(V);}
	inline Vector4 VectorPow(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorPow(V1,V2);}
	inline Vector4 VectorAbs(Vector4Param V){return DirectX::XMVectorAbs(V);}
	inline Vector4 VectorMod(Vector4Param V1, Vector4Param V2){return DirectX::XMVectorMod(V1,V2);}
	inline Vector4 VectorModAngles(Vector4Param Angles){return DirectX::XMVectorModAngles(Angles);}
	inline Vector4 VectorSin(Vector4Param V){return DirectX::XMVectorSin(V);}
	inline Vector4 VectorSinEst(Vector4Param V){return DirectX::XMVectorSinEst(V);}
	inline Vector4 VectorCos(Vector4Param V){return DirectX::XMVectorCos(V);}
	inline Vector4 VectorCosEst(Vector4Param V){return DirectX::XMVectorCosEst(V);}
	inline void VectorSinCos(_Out_ Vector4* pSin, _Out_ Vector4* pCos, _In_ Vector4Param V){return DirectX::XMVectorSinCos(pSin,pCos,V);}
	inline void VectorSinCosEst(_Out_ Vector4* pSin, _Out_ Vector4* pCos, _In_ Vector4Param V){return DirectX::XMVectorSinCosEst(pSin,pCos,V);}
	inline Vector4 VectorTan(Vector4Param V){return DirectX::XMVectorTan(V);}
	inline Vector4 VectorTanEst(Vector4Param V){return DirectX::XMVectorTanEst(V);}
	inline Vector4 VectorSinH(Vector4Param V){return DirectX::XMVectorSinH(V);}
	inline Vector4 VectorCosH(Vector4Param V){return DirectX::XMVectorCosH(V);}
	inline Vector4 VectorTanH(Vector4Param V){return DirectX::XMVectorTanH(V);}
	inline Vector4 VectorASin(Vector4Param V){return DirectX::XMVectorASin(V);}
	inline Vector4 VectorASinEst(Vector4Param V){return DirectX::XMVectorASinEst(V);}
	inline Vector4 VectorACos(Vector4Param V){return DirectX::XMVectorACos(V);}
	inline Vector4 VectorACosEst(Vector4Param V){return DirectX::XMVectorACosEst(V);}
	inline Vector4 VectorATan(Vector4Param V){return DirectX::XMVectorATan(V);}
	inline Vector4 VectorATanEst(Vector4Param V){return DirectX::XMVectorATanEst(V);}
	inline Vector4 VectorATan2(Vector4Param Y, Vector4Param X){return DirectX::XMVectorATan2(Y,X);}
	inline Vector4 VectorATan2Est(Vector4Param Y, Vector4Param X){return DirectX::XMVectorATan2Est(Y,X);}
	inline Vector4 VectorLerp(Vector4Param V0, Vector4Param V1, float t){return DirectX::XMVectorLerp(V0,V1,t);}
	inline Vector4 VectorLerpV(Vector4Param V0, Vector4Param V1, Vector4Param T){return DirectX::XMVectorLerpV(V0,V1,T);}
	inline Vector4 VectorHermite(Vector4Param Position0, Vector4Param Tangent0, Vector4Param Position1, Vector4Param4 Tangent1, float t)
	{
		return DirectX::XMVectorHermite(Position0,Tangent0,Position1,Tangent1, t);
	}
	inline Vector4 VectorHermiteV(Vector4Param Position0, Vector4Param Tangent0, Vector4Param Position1, Vector4Param4 Tangent1, Vector4ParamX T)
	{
		return DirectX::XMVectorHermiteV(Position0,Tangent0,Position1,Tangent1,T);
	}
	inline Vector4 VectorCatmullRom(Vector4Param Position0, Vector4Param Position1, Vector4Param Position2, Vector4Param4 Position3, float t)
	{
		return DirectX::XMVectorCatmullRom(Position0,Position1,Position2,Position3,t);
	}
	inline Vector4 VectorCatmullRomV(Vector4Param Position0, Vector4Param Position1, Vector4Param Position2, Vector4Param4 Position3, Vector4ParamX T)
	{
		return DirectX::XMVectorCatmullRomV(Position0,Position1,Position2,Position3,T);
	}
	inline Vector4 VectorBaryCentric(Vector4Param Position0, Vector4Param Position1, Vector4Param Position2, float f, float g)
	{
		return DirectX::XMVectorBaryCentric(Position0,Position1,Position2,f,g);
	}
	inline Vector4 VectorBaryCentricV(Vector4Param Position0, Vector4Param Position1, Vector4Param Position2, Vector4Param4 F, Vector4ParamX G)
	{
		return DirectX::XMVectorBaryCentricV(Position0,Position1,Position2,F,G);
	}

	/****************************************************************************
	*
	* 2D vector operations
	*
	****************************************************************************/
	inline bool Vector2Equal(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2Equal(V1,V2);}
	inline uint32_t Vector2EqualR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2EqualR(V1,V2);}
	inline bool Vector2EqualInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2EqualInt(V1,V2);}
	inline uint32_t Vector2EqualIntR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2EqualIntR(V1,V2);}
	inline bool Vector2NearEqual(Vector4Param V1, Vector4Param V2, Vector4Param Epsilon){return DirectX::XMVector2NearEqual(V1,V2,Epsilon);}
	inline bool Vector2NotEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2NotEqual(V1,V2);}
	inline bool Vector2NotEqualInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2NotEqualInt(V1,V2);}
	inline bool Vector2Greater(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2Greater(V1,V2);}
	inline uint32_t Vector2GreaterR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2GreaterR(V1,V2);}
	inline bool Vector2GreaterOrEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2GreaterOrEqual(V1,V2);}
	inline uint32_t Vector2GreaterOrEqualR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2GreaterOrEqualR(V1,V2);}
	inline bool Vector2Less(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2Less(V1,V2);}
	inline bool Vector2LessOrEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2LessOrEqual(V1,V2);}
	inline bool Vector2InBounds(Vector4Param V, Vector4Param Bounds){return DirectX::XMVector2InBounds(V,Bounds);}

	inline bool Vector2IsNaN(Vector4Param V){return DirectX::XMVector2IsNaN(V);}
	inline bool Vector2IsInfinite(Vector4Param V){return DirectX::XMVector2IsInfinite(V);}

	inline Vector4 Vector2Dot(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2Dot(V1,V2);}
	inline Vector4 Vector2Cross(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2Cross(V1,V2);}
	inline Vector4 Vector2LengthSq(Vector4Param V){return DirectX::XMVector2LengthSq(V);}
	inline Vector4 Vector2ReciprocalLengthEst(Vector4Param V){return DirectX::XMVector2ReciprocalLengthEst(V);}
	inline Vector4 Vector2ReciprocalLength(Vector4Param V){return DirectX::XMVector2ReciprocalLength(V);}
	inline Vector4 Vector2LengthEst(Vector4Param V){return DirectX::XMVector2LengthEst(V);}
	inline Vector4 Vector2Length(Vector4Param V){return DirectX::XMVector2Length(V);}
	inline Vector4 Vector2NormalizeEst(Vector4Param V){return DirectX::XMVector2NormalizeEst(V);}
	inline Vector4 Vector2Normalize(Vector4Param V){return DirectX::XMVector2Normalize(V);}
	inline Vector4 Vector2ClampLength(Vector4Param V, float LengthMin, float LengthMax){return DirectX::XMVector2ClampLength(V,LengthMin,LengthMax);}
	inline Vector4 Vector2ClampLengthV(Vector4Param V, Vector4Param LengthMin, Vector4Param LengthMax)
	{
		return DirectX::XMVector2ClampLengthV(V,LengthMin,LengthMax);
	}
	inline Vector4 Vector2Reflect(Vector4Param Incident, Vector4Param Normal){return DirectX::XMVector2Reflect(Incident,Normal);}
	inline Vector4 Vector2Refract(Vector4Param Incident, Vector4Param Normal, float RefractionIndex)
	{
		return DirectX::XMVector2Refract(Incident,Normal,RefractionIndex);
	}
	inline Vector4 Vector2RefractV(Vector4Param Incident, Vector4Param Normal, Vector4Param RefractionIndex)
	{
		return DirectX::XMVector2RefractV(Incident,Normal,RefractionIndex);
	}
	inline Vector4 Vector2Orthogonal(Vector4Param V){return DirectX::XMVector2Orthogonal(V);}
	inline Vector4 Vector2AngleBetweenNormalsEst(Vector4Param N1, Vector4Param N2){return DirectX::XMVector2AngleBetweenNormalsEst(N1, N2);}
	inline Vector4 Vector2AngleBetweenNormals(Vector4Param N1, Vector4Param N2){return DirectX::XMVector2AngleBetweenNormals(N1,N2);}
	inline Vector4 Vector2AngleBetweenVectors(Vector4Param V1, Vector4Param V2){return DirectX::XMVector2AngleBetweenVectors(V1,V2);}
	inline Vector4 Vector2LinePointDistance(Vector4Param LinePoint1, Vector4Param LinePoint2, Vector4Param Point)
	{
		return DirectX::XMVector2LinePointDistance(LinePoint1,LinePoint2,Point);
	}
	inline Vector4 Vector2IntersectLine(Vector4Param Line1Point1, Vector4Param Line1Point2, Vector4Param Line2Point1, Vector4Param4 Line2Point2)
	{
		return DirectX::XMVector2IntersectLine(Line1Point1,Line1Point2,Line2Point1,Line2Point2);
	}
	inline Vector4 Vector2Transform(Vector4Param V, MatrixParam M){return DirectX::XMVector2Transform(V,M);}

	inline Float4* Vector2TransformStream(_Out_writes_bytes_(sizeof(Float4)+OutputStride*(VectorCount-1)) Float4* pOutputStream,
		_In_ size_t OutputStride,_In_reads_bytes_(sizeof(Float2)+InputStride*(VectorCount-1)) const Float2* pInputStream,
		_In_ size_t InputStride, _In_ size_t VectorCount, _In_ MatrixParam M)
	{
		return DirectX::XMVector2TransformStream(pOutputStream,OutputStride,pInputStream,InputStride,VectorCount,M);
	}

	inline Vector4 Vector2TransformCoord(Vector4Param V, MatrixParam M){return DirectX::XMVector2TransformCoord(V,M);}

	inline Float2* Vector2TransformCoordStream(_Out_writes_bytes_(sizeof(Float2)+OutputStride*(VectorCount-1)) Float2* pOutputStream,
		_In_ size_t OutputStride,_In_reads_bytes_(sizeof(Float2)+InputStride*(VectorCount-1)) const Float2* pInputStream,
		_In_ size_t InputStride, _In_ size_t VectorCount, _In_ MatrixParam M)
	{
		return DirectX::XMVector2TransformCoordStream(pOutputStream,OutputStride,pInputStream,InputStride,VectorCount,M);
	}
	inline Vector4 Vector2TransformNormal(Vector4Param V, MatrixParam M){return DirectX::XMVector2TransformNormal(V,M);}

	inline Float2* XMVector2TransformNormalStream(_Out_writes_bytes_(sizeof(Float2)+OutputStride*(VectorCount-1)) Float2* pOutputStream,
		_In_ size_t OutputStride,_In_reads_bytes_(sizeof(Float2)+InputStride*(VectorCount-1)) const Float2* pInputStream,
		_In_ size_t InputStride, _In_ size_t VectorCount, _In_ MatrixParam M)
	{
		return DirectX::XMVector2TransformNormalStream(pOutputStream,OutputStride,pInputStream,InputStride,VectorCount,M);
	}


	/****************************************************************************
	*
	* 3D vector operations
	*
	****************************************************************************/
	inline bool Vector3Equal(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3Equal(V1,V2);}
	inline uint32_t Vector3EqualR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3EqualR(V1,V2);}
	inline bool Vector3EqualInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3EqualInt(V1,V2);}
	inline uint32_t Vector3EqualIntR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3EqualIntR(V1,V2);}
	inline bool Vector3NearEqual(Vector4Param V1, Vector4Param V2, Vector4Param Epsilon){return DirectX::XMVector3NearEqual(V1,V2,Epsilon);}
	inline bool Vector3NotEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3NotEqual(V1, V2);}
	inline bool Vector3NotEqualInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3NotEqualInt(V1,V2);}
	inline bool Vector3Greater(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3Greater(V1,V2);}
	inline uint32_t Vector3GreaterR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3GreaterR(V1,V2);}
	inline bool Vector3GreaterOrEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3GreaterOrEqual(V1,V2);}
	inline uint32_t Vector3GreaterOrEqualR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3GreaterOrEqualR(V1,V2);}
	inline bool Vector3Less(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3Less(V1,V2);}
	inline bool Vector3LessOrEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3LessOrEqual(V1,V2);}
	inline bool Vector3InBounds(Vector4Param V, Vector4Param Bounds){return DirectX::XMVector3InBounds(V,Bounds);}
		 
	inline bool Vector3IsNaN(Vector4Param V){return DirectX::XMVector3IsNaN(V);}
	inline bool Vector3IsInfinite(Vector4Param V){return DirectX::XMVector3IsInfinite(V);}

	inline Vector4 Vector3Dot(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3Dot(V1,V2);}
	inline Vector4 Vector3Cross(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3Cross(V1,V2);}
	inline Vector4 Vector3LengthSq(Vector4Param V){return DirectX::XMVector3LengthSq(V);}
	inline Vector4 Vector3ReciprocalLengthEst(Vector4Param V){return DirectX::XMVector3ReciprocalLengthEst(V);}
	inline Vector4 Vector3ReciprocalLength(Vector4Param V){return DirectX::XMVector3ReciprocalLength(V);}
	inline Vector4 Vector3LengthEst(Vector4Param V){return DirectX::XMVector3LengthEst(V);}
	inline Vector4 Vector3Length(Vector4Param V){return DirectX::XMVector3Length(V);}
	inline Vector4 Vector3NormalizeEst(Vector4Param V){return DirectX::XMVector3NormalizeEst(V);}
	inline Vector4 Vector3Normalize(Vector4Param V){return DirectX::XMVector3Normalize(V);}
	inline Vector4 Vector3ClampLength(Vector4Param V, float LengthMin, float LengthMax){return DirectX::XMVector3ClampLength(V,LengthMin,LengthMax);}
	inline Vector4 Vector3ClampLengthV(Vector4Param V, Vector4Param LengthMin, Vector4Param LengthMax){return DirectX::XMVector3ClampLengthV(V,LengthMin,LengthMax);}
	inline Vector4 Vector3Reflect(Vector4Param Incident, Vector4Param Normal){return DirectX::XMVector3Reflect(Incident,Normal);}
	inline Vector4 Vector3Refract(Vector4Param Incident, Vector4Param Normal, float RefractionIndex){return DirectX::XMVector3Refract(Incident,Normal,RefractionIndex);}
	inline Vector4 Vector3RefractV(Vector4Param Incident, Vector4Param Normal, Vector4Param RefractionIndex){return DirectX::XMVector3RefractV(Incident,Normal,RefractionIndex);}
	inline Vector4 Vector3Orthogonal(Vector4Param V){return DirectX::XMVector3Orthogonal(V);}
	inline Vector4 Vector3AngleBetweenNormalsEst(Vector4Param N1, Vector4Param N2){return DirectX::XMVector3AngleBetweenNormalsEst(N1,N2);}
	inline Vector4 Vector3AngleBetweenNormals(Vector4Param N1, Vector4Param N2){return DirectX::XMVector3AngleBetweenNormals(N1,N2);}
	inline Vector4 Vector3AngleBetweenVectors(Vector4Param V1, Vector4Param V2){return DirectX::XMVector3AngleBetweenVectors(V1,V2);}
	inline Vector4 Vector3LinePointDistance(Vector4Param LinePoint1, Vector4Param LinePoint2, Vector4Param Point){return DirectX::XMVector3LinePointDistance(LinePoint1,LinePoint2,Point);}
	inline void    Vector3ComponentsFromNormal(_Out_ Vector4* pParallel, _Out_ Vector4* pPerpendicular, _In_ Vector4Param V, _In_ Vector4Param Normal)
	{
		return DirectX::XMVector3ComponentsFromNormal(pParallel,pPerpendicular,V,Normal);
	}
	inline Vector4 Vector3Rotate(Vector4Param V, Vector4Param RotationQuaternion){return DirectX::XMVector3Rotate(V,RotationQuaternion);}
	inline Vector4 Vector3InverseRotate(Vector4Param V, Vector4Param RotationQuaternion){return DirectX::XMVector3InverseRotate(V,RotationQuaternion);}
	inline Vector4 Vector3Transform(Vector4Param V, MatrixParam M){return DirectX::XMVector3Transform(V,M);}

	inline Float4* XMVector3TransformStream(_Out_writes_bytes_(sizeof(Float4)+OutputStride*(VectorCount-1)) Float4* pOutputStream,
		_In_ size_t OutputStride,_In_reads_bytes_(sizeof(Float3)+InputStride*(VectorCount-1)) const Float3* pInputStream,
		_In_ size_t InputStride, _In_ size_t VectorCount, _In_ MatrixParam M)
	{
		return DirectX::XMVector3TransformStream(pOutputStream,OutputStride,pInputStream,InputStride,VectorCount,M);
	}
	
	inline Vector4 Vector3TransformCoord(Vector4Param V, MatrixParam M){return DirectX::XMVector3TransformCoord(V, M);}

	inline Float3* Vector3TransformCoordStream(_Out_writes_bytes_(sizeof(Float3)+OutputStride*(VectorCount-1)) Float3* pOutputStream,
		_In_ size_t OutputStride,_In_reads_bytes_(sizeof(Float3)+InputStride*(VectorCount-1)) const Float3* pInputStream,
		_In_ size_t InputStride, _In_ size_t VectorCount, _In_ MatrixParam M)
	{
		return XMVector3TransformCoordStream(pOutputStream,OutputStride,pInputStream,InputStride,VectorCount,M);
	}

	inline Vector4 Vector3TransformNormal(Vector4Param V, MatrixParam M){return DirectX::XMVector3TransformNormal(V,M);}
	inline Float3* Vector3TransformNormalStream(_Out_writes_bytes_(sizeof(Float3)+OutputStride*(VectorCount-1)) Float3* pOutputStream,
		_In_ size_t OutputStride,
		_In_reads_bytes_(sizeof(Float3)+InputStride*(VectorCount-1)) const Float3* pInputStream,
		_In_ size_t InputStride, _In_ size_t VectorCount, _In_ MatrixParam M)
	{
		return XMVector3TransformNormalStream(pOutputStream,OutputStride,pInputStream,InputStride,VectorCount,M);
	}

	inline Vector4 Vector3Project(Vector4Param V, float ViewportX, float ViewportY, float ViewportWidth, float ViewportHeight, float ViewportMinZ, float ViewportMaxZ, 
		MatrixParam Projection, MatrixParam View, MatrixParam World)
	{
		return DirectX::XMVector3Project(V,ViewportX,ViewportY,ViewportWidth,ViewportHeight,ViewportMinZ,ViewportMaxZ,Projection,View,World);
	}

	inline Float3* Vector3ProjectStream(_Out_writes_bytes_(sizeof(Float3)+OutputStride*(VectorCount-1)) Float3* pOutputStream,
		_In_ size_t OutputStride,_In_reads_bytes_(sizeof(Float3)+InputStride*(VectorCount-1)) const Float3* pInputStream,
		_In_ size_t InputStride, _In_ size_t VectorCount, 
		_In_ float ViewportX, _In_ float ViewportY, _In_ float ViewportWidth, _In_ float ViewportHeight, _In_ float ViewportMinZ, _In_ float ViewportMaxZ, 
		_In_ MatrixParam Projection, _In_ MatrixParam View, _In_ MatrixParam World)
	{
		return XMVector3ProjectStream(pOutputStream,OutputStride,pInputStream,InputStride,VectorCount, ViewportX,ViewportY,ViewportWidth,ViewportHeight,ViewportMinZ,
			ViewportMaxZ,Projection,View,World);
	}

	inline Vector4 XMVector3Unproject(Vector4Param V, float ViewportX, float ViewportY, float ViewportWidth, float ViewportHeight, float ViewportMinZ, float ViewportMaxZ, 
		MatrixParam Projection, MatrixParam View, MatrixParam World)
	{
		return DirectX::XMVector3Unproject(V,ViewportX,ViewportY,ViewportWidth,ViewportHeight,ViewportMinZ,ViewportMaxZ, Projection,View,World);
	}

	inline Float3* XMVector3UnprojectStream(_Out_writes_bytes_(sizeof(Float3)+OutputStride*(VectorCount-1)) Float3* pOutputStream,
		_In_ size_t OutputStride, _In_reads_bytes_(sizeof(Float3)+InputStride*(VectorCount-1)) const Float3* pInputStream,
		_In_ size_t InputStride, _In_ size_t VectorCount, 
		_In_ float ViewportX, _In_ float ViewportY, _In_ float ViewportWidth, _In_ float ViewportHeight, _In_ float ViewportMinZ, _In_ float ViewportMaxZ, 
		_In_ MatrixParam Projection, _In_ MatrixParam View, _In_ MatrixParam World)
	{
		return DirectX::XMVector3UnprojectStream(pOutputStream,OutputStride,pInputStream,InputStride,VectorCount, ViewportX,ViewportY,ViewportWidth,
			ViewportHeight,ViewportMinZ,ViewportMaxZ, Projection,View,World);
	}

	/****************************************************************************
	*
	* 4D vector operations
	*
	****************************************************************************/
	inline bool Vector4Equal(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4Equal(V1,V2);}
	inline uint32_t Vector4EqualR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4EqualR(V1,V2);}
	inline bool Vector4EqualInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4EqualInt(V1,V2);}
	inline uint32_t Vector4EqualIntR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4EqualIntR(V1,V2);}
	inline bool Vector4NearEqual(Vector4Param V1, Vector4Param V2, Vector4Param Epsilon){return DirectX::XMVector4NearEqual(V1,V2,Epsilon);}
	inline bool Vector4NotEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4NotEqual(V1, V2);}
	inline bool Vector4NotEqualInt(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4NotEqualInt(V1,V2);}
	inline bool Vector4Greater(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4Greater(V1,V2);}
	inline uint32_t Vector4GreaterR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4GreaterR(V1,V2);}
	inline bool Vector4GreaterOrEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4GreaterOrEqual(V1,V2);}
	inline uint32_t Vector4GreaterOrEqualR(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4GreaterOrEqualR(V1,V2);}
	inline bool Vector4Less(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4Less(V1,V2);}
	inline bool Vector4LessOrEqual(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4LessOrEqual(V1,V2);}
	inline bool Vector4InBounds(Vector4Param V, Vector4Param Bounds){return DirectX::XMVector4InBounds(V,Bounds);}
		 
	inline bool Vector4IsNaN(Vector4Param V){return DirectX::XMVector4IsNaN(V);}
	inline bool Vector4IsInfinite(Vector4Param V){return DirectX::XMVector4IsInfinite(V);}

	inline Vector4 Vector4Dot(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4Dot(V1,V2);}
	inline Vector4 Vector4Cross(Vector4Param V1, Vector4Param V2, Vector4Param V3){return DirectX::XMVector4Cross(V1,V2,V3);}
	inline Vector4 Vector4LengthSq(Vector4Param V){return DirectX::XMVector4LengthSq(V);}
	inline Vector4 Vector4ReciprocalLengthEst(Vector4Param V){return DirectX::XMVector4ReciprocalLengthEst(V);}
	inline Vector4 Vector4ReciprocalLength(Vector4Param V){return DirectX::XMVector4ReciprocalLength(V);}
	inline Vector4 Vector4LengthEst(Vector4Param V){return DirectX::XMVector4LengthEst(V);}
	inline Vector4 Vector4Length(Vector4Param V){return DirectX::XMVector4Length(V);}
	inline Vector4 Vector4NormalizeEst(Vector4Param V){return DirectX::XMVector4NormalizeEst(V);}
	inline Vector4 Vector4Normalize(Vector4Param V){return DirectX::XMVector4Normalize(V);}
	inline Vector4 Vector4ClampLength(Vector4Param V, float LengthMin, float LengthMax){return DirectX::XMVector4ClampLength(V,LengthMin,LengthMax);}
	inline Vector4 Vector4ClampLengthV(Vector4Param V, Vector4Param LengthMin, Vector4Param LengthMax){return DirectX::XMVector4ClampLengthV(V,LengthMin,LengthMax);}
	inline Vector4 Vector4Reflect(Vector4Param Incident, Vector4Param Normal){return DirectX::XMVector4Reflect(Incident,Normal);}
	inline Vector4 Vector4Refract(Vector4Param Incident, Vector4Param Normal, float RefractionIndex){return DirectX::XMVector4Refract(Incident,Normal,RefractionIndex);}
	inline Vector4 Vector4RefractV(Vector4Param Incident, Vector4Param Normal, Vector4Param RefractionIndex){return DirectX::XMVector4RefractV(Incident,Normal,RefractionIndex);}
	inline Vector4 Vector4Orthogonal(Vector4Param V){return DirectX::XMVector4Orthogonal(V);}
	inline Vector4 Vector4AngleBetweenNormalsEst(Vector4Param N1, Vector4Param N2){return DirectX::XMVector4AngleBetweenNormalsEst(N1,N2);}
	inline Vector4 Vector4AngleBetweenNormals(Vector4Param N1, Vector4Param N2){return DirectX::XMVector4AngleBetweenNormals(N1,N2);}
	inline Vector4 Vector4AngleBetweenVectors(Vector4Param V1, Vector4Param V2){return DirectX::XMVector4AngleBetweenVectors(V1,V2);}
	inline Vector4 Vector4Transform(Vector4Param V, MatrixParam M){return DirectX::XMVector4Transform(V,M);}
	inline Float4* Vector4TransformStream(_Out_writes_bytes_(sizeof(Float4)+OutputStride*(VectorCount-1)) Float4* pOutputStream,
				_In_ size_t OutputStride,_In_reads_bytes_(sizeof(Float4)+InputStride*(VectorCount-1)) const Float4* pInputStream,
                _In_ size_t InputStride, _In_ size_t VectorCount, _In_ MatrixParam M)
	{
		return DirectX::XMVector4TransformStream(pOutputStream,OutputStride,pInputStream,InputStride,VectorCount,M);
	}

	/****************************************************************************
	 *
	 * Matrix operations
	 *
	 ****************************************************************************/
	inline bool MatrixIsNaN(MatrixParam M){return DirectX::XMMatrixIsNaN(M);}
	inline bool MatrixIsInfinite(MatrixParam M){return DirectX::XMMatrixIsInfinite(M);}
	inline bool MatrixIsIdentity(MatrixParam M){return DirectX::XMMatrixIsIdentity(M);}
		
	inline Matrix MatrixMultiply(MatrixParam M1, MatrixParam M2){return DirectX::XMMatrixMultiply(M1,M2);}
	inline Matrix MatrixMultiplyTranspose(MatrixParam M1, MatrixParam M2){return DirectX::XMMatrixMultiplyTranspose(M1,M2);}
	inline Matrix MatrixTranspose(MatrixParam M){return DirectX::XMMatrixTranspose(M);}
	inline Matrix MatrixInverse(_Out_opt_ Vector4* pDeterminant, _In_ MatrixParam M){return DirectX::XMMatrixInverse(pDeterminant,M);}
	inline Vector4 MatrixDeterminant(MatrixParam M){return DirectX::XMMatrixDeterminant(M);}
	
	inline bool MatrixDecompose(_Out_ Vector4 *outScale, _Out_ Vector4 *outRotQuat, _Out_ Vector4 *outTrans, _In_ MatrixParam M)
	{
		return DirectX::XMMatrixDecompose(outScale, outRotQuat,outTrans,M);
	}

	inline Matrix MatrixIdentity(){return DirectX::XMMatrixIdentity();}
	inline Matrix MatrixSet(float m00, float m01, float m02, float m03,
		float m10, float m11, float m12, float m13,
		float m20, float m21, float m22, float m23,
		float m30, float m31, float m32, float m33)
	{
		return DirectX::XMMatrixSet( m00,  m01,  m02,  m03,m10,  m11,  m12,  m13,m20,  m21,  m22,  m23,m30,  m31,  m32,  m33);
	}

	inline Matrix MatrixTranslation(float OffsetX, float OffsetY, float OffsetZ){return DirectX::XMMatrixTranslation(OffsetX,OffsetY,OffsetZ);}
	inline Matrix MatrixTranslationFromVector(Vector4Param Offset){return DirectX::XMMatrixTranslationFromVector(Offset);}
	inline Matrix MatrixScaling(float ScaleX, float ScaleY, float ScaleZ){return DirectX::XMMatrixScaling(ScaleX,ScaleY,ScaleZ);}
	inline Matrix MatrixScalingFromVector(Vector4Param Scale){return DirectX::XMMatrixScalingFromVector(Scale);}
	inline Matrix MatrixRotationX(float Angle){return DirectX::XMMatrixRotationX(Angle);}
	inline Matrix MatrixRotationY(float Angle){return DirectX::XMMatrixRotationY(Angle);}
	inline Matrix MatrixRotationZ(float Angle){return DirectX::XMMatrixRotationZ(Angle);}
	inline Matrix MatrixRotationRollPitchYaw(float Pitch, float Yaw, float Roll){return DirectX::XMMatrixRotationRollPitchYaw(Pitch,Yaw,Roll);}
	inline Matrix MatrixRotationRollPitchYawFromVector(Vector4Param Angles){return DirectX::XMMatrixRotationRollPitchYawFromVector(Angles);}
	inline Matrix MatrixRotationNormal(Vector4Param NormalAxis, float Angle){return DirectX::XMMatrixRotationNormal(NormalAxis, Angle);}
	inline Matrix MatrixRotationAxis(Vector4Param Axis, float Angle){return DirectX::XMMatrixRotationAxis(Axis, Angle);}
	inline Matrix MatrixRotationQuaternion(Vector4Param Quaternion){return DirectX::XMMatrixRotationQuaternion(Quaternion);}

	inline Matrix MatrixTransformation2D(Vector4Param ScalingOrigin, float ScalingOrientation, Vector4Param Scaling, 
											 Vector4Param RotationOrigin, float Rotation, Vector4Param4 Translation)
	{
		return DirectX::XMMatrixTransformation2D(ScalingOrigin,ScalingOrientation,Scaling, RotationOrigin,Rotation, Translation);
	}
	inline Matrix MatrixTransformation(Vector4Param ScalingOrigin, Vector4Param ScalingOrientationQuaternion, Vector4Param Scaling, 
			Vector4Param4 RotationOrigin, Vector4ParamX RotationQuaternion, Vector4ParamX Translation)
	{
		return DirectX::XMMatrixTransformation(ScalingOrigin,ScalingOrientationQuaternion,Scaling,RotationOrigin,RotationQuaternion,Translation);
	}
	inline Matrix MatrixAffineTransformation2D(Vector4Param Scaling, Vector4Param RotationOrigin, float Rotation, Vector4Param Translation)
	{
			return DirectX::XMMatrixAffineTransformation2D(Scaling,RotationOrigin,Rotation,Translation);
	}
	inline Matrix MatrixAffineTransformation(Vector4Param Scaling, Vector4Param RotationOrigin, Vector4Param RotationQuaternion, Vector4Param4 Translation)
	{
			return DirectX::XMMatrixAffineTransformation(Scaling,RotationOrigin,RotationQuaternion,Translation);
	}
	inline Matrix MatrixReflect(Vector4Param ReflectionPlane){return DirectX::XMMatrixReflect(ReflectionPlane);}
	inline Matrix MatrixShadow(Vector4Param ShadowPlane, Vector4Param LightPosition){return DirectX::XMMatrixShadow(ShadowPlane,LightPosition);}
		   
	inline Matrix MatrixLookAtLH(Vector4Param EyePosition, Vector4Param FocusPosition, Vector4Param UpDirection)
	{
		return DirectX::XMMatrixLookAtLH(EyePosition,FocusPosition,UpDirection);
	}
	inline Matrix MatrixLookAtRH(Vector4Param EyePosition, Vector4Param FocusPosition, Vector4Param UpDirection)
	{
		return DirectX::XMMatrixLookAtRH(EyePosition,FocusPosition,UpDirection);
	}
	inline Matrix MatrixLookToLH(Vector4Param EyePosition, Vector4Param EyeDirection, Vector4Param UpDirection)
	{
		return DirectX::XMMatrixLookToLH(EyePosition,EyeDirection,UpDirection);
	}
	inline Matrix MatrixLookToRH(Vector4Param EyePosition, Vector4Param EyeDirection, Vector4Param UpDirection)
	{
			return DirectX::XMMatrixLookToRH(EyePosition,EyeDirection,UpDirection);
	}
	inline Matrix MatrixPerspectiveLH(float ViewWidth, float ViewHeight, float NearZ, float FarZ){return DirectX::XMMatrixPerspectiveLH(ViewWidth,ViewHeight,NearZ,FarZ);}
	inline Matrix MatrixPerspectiveRH(float ViewWidth, float ViewHeight, float NearZ, float FarZ){return DirectX::XMMatrixPerspectiveRH(ViewWidth,ViewHeight,NearZ,FarZ);}
	inline Matrix MatrixPerspectiveFovLH(float FovAngleY, float AspectHByW, float NearZ, float FarZ){return DirectX::XMMatrixPerspectiveFovLH(FovAngleY,AspectHByW,NearZ,FarZ);}
	inline Matrix MatrixPerspectiveFovRH(float FovAngleY, float AspectHByW, float NearZ, float FarZ){return DirectX::XMMatrixPerspectiveFovRH(FovAngleY,AspectHByW,NearZ,FarZ);}
	inline Matrix MatrixPerspectiveOffCenterLH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ)
	{
		return DirectX::XMMatrixPerspectiveOffCenterLH(ViewLeft, ViewRight, ViewBottom, ViewTop, NearZ, FarZ);
	}
	inline Matrix MatrixPerspectiveOffCenterRH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ)
	{
		return DirectX::XMMatrixPerspectiveOffCenterRH(ViewLeft, ViewRight, ViewBottom, ViewTop, NearZ, FarZ);
	}
	inline Matrix MatrixOrthographicLH(float ViewWidth, float ViewHeight, float NearZ, float FarZ){return DirectX::XMMatrixOrthographicLH(ViewWidth, ViewHeight, NearZ, FarZ);}
	inline Matrix MatrixOrthographicRH(float ViewWidth, float ViewHeight, float NearZ, float FarZ){return DirectX::XMMatrixOrthographicRH(ViewWidth, ViewHeight, NearZ, FarZ);}
	inline Matrix MatrixOrthographicOffCenterLH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ)
	{
		return DirectX::XMMatrixOrthographicOffCenterLH(ViewLeft, ViewRight, ViewBottom, ViewTop, NearZ, FarZ);
	}
	inline Matrix MatrixOrthographicOffCenterRH(float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ)
	{
		return DirectX::XMMatrixOrthographicOffCenterRH(ViewLeft, ViewRight, ViewBottom, ViewTop, NearZ, FarZ);
	}

	/****************************************************************************
	*
	* Quaternion operations
	*
	****************************************************************************/
	inline bool QuaternionEqual(Vector4Param Q1, Vector4Param Q2){return DirectX::XMQuaternionEqual(Q1,Q2);}
	inline bool QuaternionNotEqual(Vector4Param Q1, Vector4Param Q2){return DirectX::XMQuaternionNotEqual(Q1,Q2);}

	inline bool QuaternionIsNaN(Vector4Param Q){return DirectX::XMQuaternionIsNaN(Q);}
	inline bool QuaternionIsInfinite(Vector4Param Q){return DirectX::XMQuaternionIsInfinite(Q);}
	inline bool QuaternionIsIdentity(Vector4Param Q){return DirectX::XMQuaternionIsIdentity(Q);}

	inline Vector4 QuaternionDot(Vector4Param Q1, Vector4Param Q2){return DirectX::XMQuaternionDot(Q1,Q2);}
	inline Vector4 QuaternionMultiply(Vector4Param Q1, Vector4Param Q2){return DirectX::XMQuaternionMultiply(Q1,Q2);}
	inline Vector4 QuaternionLengthSq(Vector4Param Q){return DirectX::XMQuaternionLengthSq(Q);}
	inline Vector4 QuaternionReciprocalLength(Vector4Param Q){return DirectX::XMQuaternionReciprocalLength(Q);}
	inline Vector4 QuaternionLength(Vector4Param Q){return DirectX::XMQuaternionLength(Q);}
	inline Vector4 QuaternionNormalizeEst(Vector4Param Q){return DirectX::XMQuaternionNormalizeEst(Q);}
	inline Vector4 QuaternionNormalize(Vector4Param Q){return DirectX::XMQuaternionNormalize(Q);}
	inline Vector4 QuaternionConjugate(Vector4Param Q){return DirectX::XMQuaternionConjugate(Q);}
	inline Vector4 QuaternionInverse(Vector4Param Q){return DirectX::XMQuaternionInverse(Q);}
	inline Vector4 QuaternionLn(Vector4Param Q){return DirectX::XMQuaternionLn(Q);}
	inline Vector4 QuaternionExp(Vector4Param Q){return DirectX::XMQuaternionExp(Q);}
	inline Vector4 QuaternionSlerp(Vector4Param Q0, Vector4Param Q1, float t){return DirectX::XMQuaternionSlerp(Q0,Q1,t);}
	inline Vector4 QuaternionSlerpV(Vector4Param Q0, Vector4Param Q1, Vector4Param T){return DirectX::XMQuaternionSlerpV(Q0,Q1,T);}
	inline Vector4 QuaternionSquad(Vector4Param Q0, Vector4Param Q1, Vector4Param Q2, Vector4Param4 Q3, float t){return DirectX::XMQuaternionSquad(Q0,Q1,Q2,Q3,t);}
	inline Vector4 QuaternionSquadV(Vector4Param Q0, Vector4Param Q1, Vector4Param Q2, Vector4Param4 Q3, Vector4Param4 T){return DirectX::XMQuaternionSquadV(Q0,Q1,Q2,Q3,T);}
	inline void    QuaternionSquadSetup(_Out_ Vector4* pA, _Out_ Vector4* pB, _Out_ Vector4* pC, _In_ Vector4Param Q0, _In_ Vector4Param Q1, _In_ Vector4Param Q2, _In_ Vector4Param4 Q3)
	{ 
		return DirectX::XMQuaternionSquadSetup(pA,pB,pC,Q0,Q1,Q2,Q3);
	}
	inline Vector4 QuaternionBaryCentric(Vector4Param Q0, Vector4Param Q1, Vector4Param Q2, float f, float g)
	{
		return DirectX::XMQuaternionBaryCentric(Q0,Q1,Q2,f,g);
	}
	inline Vector4 QuaternionBaryCentricV(Vector4Param Q0, Vector4Param Q1, Vector4Param Q2, Vector4Param4 F, Vector4Param4 G)
	{
		return DirectX::XMQuaternionBaryCentricV(Q0,Q1,Q2,F,G);
	}
	inline Vector4 QuaternionIdentity(){return DirectX::XMQuaternionIdentity();}
	inline Vector4 QuaternionRotationRollPitchYaw(float Pitch, float Yaw, float Roll){return DirectX::XMQuaternionRotationRollPitchYaw(Pitch,Yaw,Roll);}
	inline Vector4 QuaternionRotationRollPitchYawFromVector(Vector4Param Angles){return DirectX::XMQuaternionRotationRollPitchYawFromVector(Angles);}
	inline Vector4 QuaternionRotationNormal(Vector4Param NormalAxis, float Angle){return DirectX::XMQuaternionRotationNormal(NormalAxis, Angle);}
	inline Vector4 QuaternionRotationAxis(Vector4Param Axis, float Angle){return DirectX::XMQuaternionRotationAxis(Axis,Angle);}
	inline Vector4 QuaternionRotationMatrix(MatrixParam M){return DirectX::XMQuaternionRotationMatrix(M);}

	inline void XMQuaternionToAxisAngle(_Out_ Vector4* pAxis, _Out_ float* pAngle, _In_ Vector4Param Q)
	{
		return DirectX::XMQuaternionToAxisAngle(pAxis,pAngle,Q);
	}

	/****************************************************************************
	 *
	 * Plane operations
	 *
	 ****************************************************************************/
	inline bool PlaneEqual(Vector4Param P1, Vector4Param P2){return DirectX::XMPlaneEqual(P1,P2);}
	inline bool PlaneNearEqual(Vector4Param P1, Vector4Param P2, Vector4Param Epsilon){return DirectX::XMPlaneNearEqual(P1,P2,Epsilon);}
	inline bool PlaneNotEqual(Vector4Param P1, Vector4Param P2){return DirectX::XMPlaneNotEqual(P1,P2);}

	inline bool PlaneIsNaN(Vector4Param P){return DirectX::XMPlaneIsNaN(P);}
	inline bool PlaneIsInfinite(Vector4Param P){return DirectX::XMPlaneIsInfinite(P);}
	inline Vector4 PlaneDot(Vector4Param P, Vector4Param V){return DirectX::XMPlaneDot(P,V);}
	inline Vector4 PlaneDotCoord(Vector4Param P, Vector4Param V){return DirectX::XMPlaneDotCoord(P,V);}
	inline Vector4 PlaneDotNormal(Vector4Param P, Vector4Param V){return DirectX::XMPlaneDotNormal(P,V);}
	inline Vector4 PlaneNormalizeEst(Vector4Param P){return DirectX::XMPlaneNormalizeEst(P);}
	inline Vector4 PlaneNormalize(Vector4Param P){return DirectX::XMPlaneNormalize(P);}
	inline Vector4 PlaneIntersectLine(Vector4Param P, Vector4Param LinePoint1, Vector4Param LinePoint2){return DirectX::XMPlaneIntersectLine(P,LinePoint1,LinePoint2);}
	inline void    PlaneIntersectPlane(_Out_ Vector4* pLinePoint1, _Out_ Vector4* pLinePoint2, _In_ Vector4Param P1, _In_ Vector4Param P2)
	{
		return DirectX::XMPlaneIntersectPlane(pLinePoint1,pLinePoint2,P1,P2);
	}
	inline Vector4 PlaneTransform(Vector4Param P, MatrixParam M){return DirectX::XMPlaneTransform(P,M);}

	inline Float4* PlaneTransformStream(_Out_writes_bytes_(sizeof(Float4)+OutputStride*(PlaneCount-1)) Float4* pOutputStream,
				_In_ size_t OutputStride,_In_reads_bytes_(sizeof(Float4)+InputStride*(PlaneCount-1)) const Float4* pInputStream,
				_In_ size_t InputStride, _In_ size_t PlaneCount, _In_ MatrixParam M)
	{
		return DirectX::XMPlaneTransformStream(pOutputStream,OutputStride,pInputStream,InputStride,PlaneCount,M);
	}

	inline Vector4 XMPlaneFromPointNormal(Vector4Param Point, Vector4Param Normal){return DirectX::XMPlaneFromPointNormal(Point,Normal);}
	inline Vector4 XMPlaneFromPoints(Vector4Param Point1, Vector4Param Point2, Vector4Param Point3){return DirectX::XMPlaneFromPoints(Point1,Point2,Point3);}

	/****************************************************************************
	 *
	 * Color operations
	 *
	 ****************************************************************************/
	inline bool ColorEqual(Vector4Param C1, Vector4Param C2){return DirectX::XMColorEqual(C1,C2);}
	inline bool ColorNotEqual(Vector4Param C1, Vector4Param C2){return DirectX::XMColorNotEqual(C1,C2);}
	inline bool ColorGreater(Vector4Param C1, Vector4Param C2){return DirectX::XMColorGreater(C1,C2);}
	inline bool ColorGreaterOrEqual(Vector4Param C1, Vector4Param C2){return DirectX::XMColorGreaterOrEqual(C1,C2);}
	inline bool ColorLess(Vector4Param C1, Vector4Param C2){return DirectX::XMColorLess(C1,C2);}
	inline bool ColorLessOrEqual(Vector4Param C1, Vector4Param C2){return DirectX::XMColorLessOrEqual(C1,C2);}

	inline bool ColorIsNaN(Vector4Param C){return DirectX::XMColorIsNaN(C);}
	inline bool ColorIsInfinite(Vector4Param C){return DirectX::XMColorIsInfinite(C);}
	
	inline Vector4 ColorNegative(Vector4Param C){return DirectX::XMColorNegative(C);}
	inline Vector4 ColorModulate(Vector4Param C1, Vector4Param C2){return DirectX::XMColorModulate(C1,C2);}
	inline Vector4 ColorAdjustSaturation(Vector4Param C, float Saturation){return DirectX::XMColorAdjustSaturation(C,Saturation);}
	inline Vector4 ColorAdjustContrast(Vector4Param C, float Contrast){return DirectX::XMColorAdjustContrast(C,Contrast);}

	inline Vector4 ColorRGBToHSL( Vector4Param rgb ){return DirectX::XMColorRGBToHSL(rgb);}
	inline Vector4 ColorHSLToRGB( Vector4Param hsl ){return DirectX::XMColorHSLToRGB(hsl);}

	inline Vector4 ColorRGBToHSV( Vector4Param rgb ){return DirectX::XMColorRGBToHSV(rgb);}
	inline Vector4 ColorHSVToRGB( Vector4Param hsv ){return DirectX::XMColorHSVToRGB(hsv);}

	inline Vector4 ColorRGBToYUV( Vector4Param rgb ){return DirectX::XMColorRGBToYUV(rgb);}
	inline Vector4 ColorYUVToRGB( Vector4Param yuv ){return DirectX::XMColorYUVToRGB(yuv);}

	inline Vector4 ColorRGBToYUV_HD( Vector4Param rgb ){return DirectX::XMColorRGBToYUV_HD(rgb);}
	inline Vector4 ColorYUVToRGB_HD( Vector4Param yuv ){return DirectX::XMColorYUVToRGB_HD(yuv);}

	inline Vector4 ColorRGBToXYZ( Vector4Param rgb ){return DirectX::XMColorRGBToXYZ(rgb);}
	inline Vector4 ColorXYZToRGB( Vector4Param xyz ){return DirectX::XMColorXYZToRGB(xyz);}

	inline Vector4 ColorXYZToSRGB( Vector4Param xyz ){return DirectX::XMColorXYZToSRGB(xyz);}
	inline Vector4 ColorSRGBToXYZ( Vector4Param srgb ){return DirectX::XMColorSRGBToXYZ(srgb);}


	//------------------------------------------------------------------------------
	// Vector operators
	Vector4 operator+ (Vector4Param V){return V;}
	Vector4 operator- (Vector4Param V){return VectorNegate(V);}

	Vector4& operator+= (Vector4& V1, Vector4Param V2){V1 = VectorAdd(V1,V2);return V1;}
	Vector4& operator-= (Vector4& V1, Vector4Param V2){V1 = VectorSubtract(V1,V2);return V1;}
	Vector4& operator*= (Vector4& V1, Vector4Param V2){V1 = VectorMultiply(V1,V2);return V1;}
	Vector4& operator/= (Vector4& V1, Vector4Param V2){V1 = VectorDivide(V1,V2);return V1;}
	Vector4& operator*= (Vector4& V, float S){V = VectorScale(V,S);return V;}
	Vector4& operator/= (Vector4& V, float S){assert(S!=0.0f);V=VectorScale(V,1.0f/S);return V;}

	Vector4 operator+ (Vector4Param V1, Vector4Param V2){return VectorAdd(V1,V2);}
	Vector4 operator- (Vector4Param V1, Vector4Param V2){return VectorSubtract(V1,V2);}
	Vector4 operator* (Vector4Param V1, Vector4Param V2){return VectorMultiply(V1,V2);}
	Vector4 operator/ (Vector4Param V1, Vector4Param V2){return VectorDivide(V1,V2);}
	Vector4 operator* (Vector4Param V, float S){return VectorScale(V,S);}
	Vector4 operator* (float S, Vector4Param V){return VectorScale(V,S);}
	Vector4 operator/ (Vector4Param V, float S){assert(S != 0.0f);return VectorScale(V,1.0f/S);}
}

#include "DXMathExtension.inl"